<%@ page language="java" import="java.util.*,com.hs.core.cache.*" pageEncoding="utf-8"%>
<%
   List typelist = (List)request.getAttribute("typelist");
   List catalist = (List)request.getAttribute("catalist");
   String pageStr = (String)request.getAttribute("pagestr");
   List datalist = (List)request.getAttribute("datalist");
   String orderName = (String)request.getAttribute("orderName");
   String orderNum = (String)request.getAttribute("orderNum"); 
   String allsql = (String)request.getAttribute("allsql"); 
   String searchtype = (String)request.getAttribute("searchtype");
   	String pagenum = (String)request.getAttribute("pagenum");
	String pagecount = (String)request.getAttribute("pagecount");
	
	int pagenumInt = Integer.parseInt(pagenum);
	int pagecountInt = Integer.parseInt(pagecount);

	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<%@ include file="../../include.jsp"%> 
<script src="<%=basePath %>app/javascripts/transform.js"></script>
<script language=JavaScript>
 //题录信息
 function magaInfo(id)
{
	var pageURL = "<%=basePath %>data/magainfo.do?id=" + id;
	openwindow(pageURL,'800','600',''); 
}
//详细数据信息
 function auditInfo(id){
	var pageURL = "<%=basePath %>audit/auditlistFrame.do?id=" + id;
	openwindow(pageURL,'1000','800',''); 
    //window.location.href=pageURL;
 }
 
 function searchViewGeneral(){
     var s1 = document.getElementById("magasearch");
     var s2 = document.getElementById("specialsearch"); 
     if(s1.style != null){
     	s1.style.display="";
     }
     if(s2.style != null){
     	s2.style.display="none";
     }
 }
 function searchViewSpecial(){
     var s1 = document.getElementById("magasearch");
     var s2 = document.getElementById("specialsearch"); 
     if(s1.style != null){
     	s1.style.display="none";
     }
     if(s2.style != null){
     	s2.style.display="";
     }
 }

 function resetAll(){
 	var   obj   =   document.all.tags("input"); 
	for(i=0;i <obj.length;i++){ 
    if(obj[i].type== "text"){ 
            obj[i].value   =   ""; 
    } 
}
 
 }
 function ge(a){return document.getElementById(a)}
 function AddRowEx(divid,divindex,divcount){
 	try{
		if(ge(divindex).value==ge(divcount).value){
			return
		}
		var curID=parseInt($("#"+divindex).val());
		var copyID=curID+1;
		var curTrID=divid+"_"+curID.toString();
		var copyTrID=divid+"_"+copyID.toString();
		//alert(curTrID + "," + copyTrID);
		var copyHtml="";
		if($("#"+copyTrID).html()!=null){
			$("#"+copyTrID).show()
		}else{
			var cloneObj=$("#"+curTrID).clone();
			if(curID==1){
				if(cloneObj.find("td:first")!=null){
					cloneObj.find("td:first").remove()
				}
				if(cloneObj.find("span:first")!=null){
					cloneObj.find("span:first").remove()
				}
				var logicalTd=$("#hidden_logical_"+divid).html();
				if(logicalTd!=""){
					var reg=/{key}/g;
					logicalTd=logicalTd.replace(reg,copyTrID);
					cloneObj=cloneObj.prepend(logicalTd)
				}
			}
			copyHtml=$("<div></div>").append(cloneObj).html();
			var reg1=eval("/"+curTrID+"/g");
			copyHtml=copyHtml.replace(reg1,divid+"_"+copyID.toString());
			//alert(copyHtml);
			if(copyHtml!=""){
				$("#"+curTrID).after(copyHtml)
			}
		}
		var objvalue=ge(copyTrID+"_value1");
		if(objvalue!=null){
			objvalue.value=""
		}
		objvalue=ge(copyTrID+"_value2");
		if(objvalue!=null){
			objvalue.value=""
		}
		ge(divindex).value=copyID.toString();
		var obj=ge(copyTrID+"_sel");
		if(!obj){
			obj=ge(copyTrID+"_sel1")
		}
		if(obj){
			obj.options[copyID-1].selected=true;
			obj.onchange()
		}
	}catch(e){
	}
 }
 function DeleteRow(h,c,b){
	try{
		if(ge(c).value=="1"){
			return
		}else{
			var g=parseInt(ge(c).value);
			var f=h+"_"+g;var a=ge(f+"_value1");
			if(a!=null){
				a.value=""
			}
			a=ge(f+"_value2");
			if(a!=null){
				a.value=""
			}
			ge(f).style.display="none";
			g--;
			ge(c).value=g
		}
	}catch(d){
	return
	}
}

function specialSearch(condition){
	var divid = "spec_";
	var onestr = "";
	if(onestr != ""){
		onestr = "";
	}
	for(var i=1; i<=14; i++){
		var divcur = divid + i + "_value";
		var curobj = document.getElementById(divcur);
		var curvalueStr = divid+i+"_value";
		var curlogicStr = divid+i+"_logical";
		var curselStr = divid+i+"_sel";
		var curspecialStr = divid+i+"_special";
		
		if(curobj != undefined ){
			if(curobj.value != "")
			{
				var curvalue = curobj.value;
				if(i !=1){
					var curlogic = document.getElementById(curlogicStr).value;
				}else{
					var curlogic = 0 ;
				}
				var cursel = document.getElementById(curselStr).value;
				var curspecial = document.getElementById(curspecialStr).value;
				if(onestr.indexOf("&")!=-1){
					onestr = onestr + "&";
				}
				onestr = onestr + curvalueStr+"="+curvalue+"&"+curlogicStr+"="+curlogic+"&"+curselStr+"="+cursel+"&"+curspecialStr+"="+curspecial;
			}
		}
		
	}
	var proid = "pro_";
	for(var j=1; j<=14; j++){
		var divcur = proid + j + "_value";
		var curobj = document.getElementById(divcur);
		var curvalueStr = proid+j+"_value";
		var curlogicStr = proid+j+"_logical";
		var curselStr = proid+j+"_sel";
		var curspecialStr = proid+j+"_special";
		var cursynStr = proid+j+"_syn";
		if(curobj != undefined ){
			if(curobj.value != "")
			{
				var curvalue = curobj.value;
				if(j !=1){
					var curlogic = document.getElementById(curlogicStr).value;
				}else{
					var curlogic = 0 ;
				}
				var cursel = document.getElementById(curselStr).value;
				var curspecial = document.getElementById(curspecialStr).value;
				var cursyn = document.getElementById(cursynStr).value;
				if(onestr.indexOf("&")!=-1){
					onestr = onestr + "&";
				}
				onestr = onestr + curvalueStr+"="+curvalue+"&"+curlogicStr+"="+curlogic+"&"+curselStr+"="+cursel+"&"+curspecialStr+"="+curspecial+"&"+cursynStr+"="+cursyn;
			}
		}
		
	}
	var srcStr = "" ;
	if(onestr != ""){
		srcStr = "?" + onestr;
		if(condition != ""){
			srcStr = srcStr + "&" + condition;
		}
	}else{
		if(condition != ""){
			srcStr = "?" + condition;
		}
	}
	document.getElementById("bookframe").src="<%=basePath %>search/doSearch.do"+srcStr;
}

function generalSearch(condition){
	var divid = "txt_";
	var onestr = "";
	for(var i=1; i<=14; i++){
		var divcur = divid + i + "_value";
		var curobj = document.getElementById(divcur);
		var curvalueStr = divid+i+"_value";
		var curlogicStr = divid+i+"_logical";
		var curselStr = divid+i+"_sel";
		var curspecialStr = divid+i+"_special";
		
		if(curobj != undefined ){
			if(curobj.value != "")
			{
				var curvalue = curobj.value;
				if(i !=1){
					var curlogic = document.getElementById(curlogicStr).value;
				}else{
					var curlogic = 0 ;
				}
				var cursel = document.getElementById(curselStr).value;
				var curspecial = document.getElementById(curspecialStr).value;
				if(onestr.indexOf("&")!=-1){
					onestr = onestr + "&";
				}
				onestr = onestr + curvalueStr+"="+curvalue+"&"+curlogicStr+"="+curlogic+"&"+curselStr+"="+cursel+"&"+curspecialStr+"="+curspecial;
			}
		}
		
	}
	
	var srcStr = "" ;
	if(onestr != ""){
		srcStr = "?" + onestr;
		if(condition != ""){
			srcStr = srcStr + "&" + condition;
		}
	}else{
		if(condition != ""){
			srcStr = "?" + condition;
		}
	}
	
	document.getElementById("bookframe").src="<%=basePath %>search/sindex3.do"+srcStr;
}
function firstClass(type){
	 var s1 = document.getElementById("magasearch");
     var s2 = document.getElementById("specialsearch"); 
     var condition = "firstclass="+type;
     if(s1.style.display == ""){
     	generalSearch(condition);
     }
     if(s2.style.display == ""){
     	specialSearch(condition);
     }
	
}

function diseaseClass(type){
	 var s1 = document.getElementById("magasearch");
     var s2 = document.getElementById("specialsearch"); 
     var condition = "diseaseclass="+type;
     if(s1.style.display == ""){
     	generalSearch(condition);
     }
     if(s2.style.display == ""){
     	specialSearch(condition);
     }
	
}
function s2t()
{
	//document.body.innerHTML = document.body.innerHTML.s2t();
	window.frames.bookframe.document.body.innerHTML = window.frames.bookframe.document.body.innerHTML.s2t();
	document.all.fonttype.value='ft';
}
function t2s()
{
	//document.body.innerHTML = document.body.innerHTML.t2s();
	window.frames.bookframe.document.body.innerHTML = window.frames.bookframe.document.body.innerHTML.t2s();
	document.all.fonttype.value='jt';
}


</script>
</head>
<body style="overflow:auto">
<div class="cont">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
   <td style="width:185px" valign="top">
   <dl class="deta_sear_menu">
		<dt>原文分类</dt>
		 <dd>
		    <%if(null != typelist && typelist.size()>0){
                 for(int i =0;i<typelist.size();i++){
                 	Map typemap = (Map)typelist.get(i);
                 	String firstclass = (String)typemap.get("firstclass");
                 	String typecount = typemap.get("countall") + "";
                 	//String temp = DictCacheUtil.getInst().selectStr4Display(typestr,"20");
               %>  
              <a  title="<%=firstclass %>" onClick="firstClass('<%= firstclass%>');"><span><font color=red><%=typecount %></font>篇</span><%=StringUtilTool.subTitle(firstclass,12)%></a>
            
            <% }} %> 
        </dd>
		<dt>疾病分类</dt>
        <dd>
            <%if(null != catalist && catalist.size()>0){
                 for(int j =0;j<catalist.size();j++){
                 	Map catamap = (Map)catalist.get(j);
                 	String DISEASECLASS =   catamap.get("DISEASECLASS") +"";
                 	String catacount = catamap.get("countall") + "";
                 	//String temp1 = DictCacheUtil.getInst().selectStr4Display(catastr,"21");
                %>  
              <a title="<%=DISEASECLASS%>" onClick="diseaseClass('<%= DISEASECLASS%>');"><span><font color=red><%=catacount %></font>篇</span><%=StringUtilTool.subTitle(DISEASECLASS,12) %></a>
            
            <% }} %> 
        </dd>
   </dl>
   </td>
   <td valign="top">
   <div class="deta_sear_list">
   	   <div class="sear"> 
   	   <!-- <ul><%=allsql %></ul>-->

   	   <ul>
   	    	<li class="curr"><a href="javascript:searchViewGeneral();">简单检索</a></li>
   	    	<li><a href="javascript:searchViewSpecial();">高级检索</a></li>
   	   </ul> 
  <form name="searchform" method="post" action="<%=basePath %>search/sindex.do" method=post>
    
    <div id="magasearch" style="display:<%if("1".equals(searchtype)){ out.println("");}else{out.println("none");} %>">
     <fieldset>
 	     <table id="txt" width="100%" border="0" cellspacing="0" cellpadding="0" class="deta_list_sear">
 	     
 	    	<input id="txt_i" value="1" type="hidden" name="txt_i"></input>
            <input id="txt_c" value="14" type="hidden" name="txt_c"></input>
            <tr id="hidden_logical_txt" style="display:none">
                <td nowrap="true" style="width:10%;" align="right" >
                    <select id="{key}_logical" name="{key}_logical">
                        <option value="0" selected="">并且</option>
                        <option value="1">或者</option>
                    </select> 
                </td>
         </tr>
	     <tr id="txt_1">
	     <td nowrap="true" width="10%">
	    			<input onclick="AddRowEx('txt','txt_i','txt_c');" type="button" value="+" class="but_2"/>
	    			<input onclick="DeleteRow('txt','txt_i','txt_c');" type="button" value="-" class="but_2"/>
         </td>
	     <td width="10%">
		     <select id='txt_1_sel' name='txt_1_sel'>
	             <option value='itemno' selected=''>条目编码</option>
	             <option value='bookname'>书籍名称</option>
	             <option value='diseasename'>古代中医病名</option>
	             <option value='firstclass'>原文分类</option>
	             <option value='originaltext'>原文文本化</option>
	             <option value='author'>古籍作者</option>
	             <option value='compile'>古籍编辑</option>
	             <option value='compileunit'>编辑单位</option>
	             <option value='publishhouse'>出版社</option>
	             <option value='publishplace'>出版地</option>
	             <option value='publishdate'>出版日期</option>
	             <option value='themewords'>主题/关键词</option>
	             <option value='abstract'>摘要</option>
	             <option value='dynasty'>朝代</option>
	         </select>
	     </td>
	      <td width="75%" >
	     	<input name="txt_1_value" id="txt_1_value" type="text" value="" style="width:99%" class="sear_input"/>
	     </td>
	      <td width="5%">
		     <select id="txt_1_special" name="txt_1_special" style="100%">
			     <option value=0 selected>精确</option>
			     <option value=1>模糊</option>
		     </select>
	     </td>
	     </tr>
	    </table>
	    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="deta_list_sear"> 
	     <tr> 
	     <td width="30%" align=center>&nbsp;</td>
	     <td width="10%" align=center><input   type="button" onclick="generalSearch('');" value="检索" class="butt2"/></td>
	     <td width="10%"><input type="button" value="重置" onclick="resetAll();" class="butt4"/></td>
	     <td width="10%"><input type="button" value="简体" onclick="t2s();" class="butt4"/></td>
	     <td width="10%"><input type="button" value="繁体" onclick="s2t();" class="butt4"/>
	     <input name="fonttype" id="fonttype" type="hidden" value="jt"/></td>
	     <td width="30%" align=center>&nbsp;</td>
	     </tr>  
     </table> 
	</fieldset> 
	
	</div>
	<div id=specialsearch style="display:<%if("2".equals(searchtype)){ out.println("");}else{out.println("none");} %>">
	
	 <fieldset>
 	     <table id="spec" width="100%" border="0" cellspacing="0" cellpadding="0" class="deta_list_sear">
 	     
 	    	<input id="spec_i" value="1" type="hidden" name="spec_i"></input>
            <input id="spec_c" value="14" type="hidden" name="spec_c"></input>
            <tr id="hidden_logical_spec" style="display:none">
                <td nowrap="true" style="width:10%;" align="right" >
                    <select id="{key}_logical" name="{key}_logical">
                        <option value="0" selected="">并且</option>
                        <option value="1">或者</option>
                    </select> 
                </td>
         </tr>
	     <tr id="spec_1">
	     <td nowrap="true" width="10%">
	    			<input onclick="AddRowEx('spec','spec_i','spec_c');" type="button" value="+" class="but_2"/>
	    			<input onclick="DeleteRow('spec','spec_i','spec_c');" type="button" value="-" class="but_2"/>
         </td>
	     <td width="10%">
		     <select id='spec_1_sel' name='spec_1_sel'>
	             <option value='itemno' selected=''>条目编码</option>
	             <option value='bookname'>书籍名称</option>
	             <option value='diseasename'>古代中医病名</option>
	             <option value='firstclass'>原文分类</option>
	             <option value='originaltext'>原文文本化</option>
	             <option value='author'>古籍作者</option>
	             <option value='compile'>古籍编辑</option>
	             <option value='compileunit'>编辑单位</option>
	             <option value='publishhouse'>出版社</option>
	             <option value='publishplace'>出版地</option>
	             <option value='publishdate'>出版日期</option>
	             <option value='themewords'>主题/关键词</option>
	             <option value='abstract_'>摘要</option>
	             <option value='dynasty'>朝代</option>
	         </select>
	     </td>
	      <td width="70%" >
	     	<input name="spec_1_value" id="spec_1_value" type="text" value="" style="width:99%" class="sear_input"/>
	     </td>
	      <td width="5%">
	     <select id="spec_1_special" name="spec_1_special" style="100%">
		     <option value=0 selected>精确</option>
		     <option value=1 >模糊</option>
	     </select>
	     </td>
	     </tr>
	    </table>
	    <table id="pro" width="100%" border="0" cellspacing="0" cellpadding="0" class="deta_list_sear">
 	     
 	    	<input id="pro_i" value="1" type="hidden" name="pro_i"></input>
            <input id="pro_c" value="8" type="hidden" name="pro_c"></input>
            <tr id="hidden_logical_pro" style="display:none">
                <td nowrap="true" style="width:10%;" align="right" >
                    <select id="{key}_logical" name="{key}_logical">
                        <option value="0" selected="">并且</option>
                        <option value="1">或者</option>
                    </select> 
                </td>
         </tr>
	     <tr id="pro_1">
	     <td nowrap="true" width="10%">
	    			<input onclick="AddRowEx('pro','pro_i','pro_c');" type="button" value="+" class="but_2"/>
	    			<input onclick="DeleteRow('pro','pro_i','pro_c');" type="button" value="-" class="but_2"/>
         </td>
	     <td width="10%">
		     <select id='pro_1_sel' name='pro_1_sel'>
	             <option value='diseasename' selected=''>古籍中医疾病</option>
	             <option value='modisnameen'>现代西医疾病</option>
	             <option value='modisnamecn'>现代中医病名</option>
	             <option value='symptomname'>证候</option>
	             <option value='prename'>方剂</option>
	             <option value='herbname'>中药</option>
	             <option value='pgroupname'>针灸组</option>
	             <option value='pointname'>穴位</option>
	         </select>
	     </td>
	      <td width="65%" >
	     	<input name="pro_1_value" id="pro_1_value" type="text" value="" style="width:99%" class="sear_input"/>
	     </td>
	      <td width="5%">
		     <select id="pro_1_special" name="pro_1_special" style="100%">
			     <option value=0 selected >精确</option>
			     <option value=1 >模糊</option>
		     </select>
	     </td>
	      <td width="5%">
		     <select id="pro_1_syn" name="pro_1_syn" style="100%">
			     <option value=0 selected >正名查询</option>
			     <option value=1 >异名查询</option>
		     </select>
	     </td>
	     </tr>
	    </table>
	    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="deta_list_sear"> 
	     <tr> 
		     <td width="30%" align=center>&nbsp;</td>
		     <td width="10%" align=center><input   type="button"  onclick="specialSearch('');" value="检索" class="butt2"/></td>
		     <td width="10%"><input type="button" value="重置" onclick="resetAll();" class="butt4"/></td>
		     <td width="10%"><input type="button" value="简体" onclick="t2s();" class="butt4"/></td>
		     <td width="10%"><input type="button" value="繁体" onclick="s2t();" class="butt4"/></td>
		     <td width="30%" align=center>&nbsp;</td>
	     </tr>  
     </table> 
	</fieldset> 
	
	</div>
   </form>
  </div> 
    <iframe src="<%=basePath%>search/sindex3.do" width="100%" frameborder="0" height="600px" id="bookframe" name="bookframe"  onload=""></iframe>
  
   </div>
    </td>
	 </tr>  
</table>
</div>
</body>
</html>


